package com.duolaibei.business.view.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.duolaibei.business.R;
import com.duolaibei.business.base.BaseDialog;

/**
 * Created by xlm on 2017/7/28 0028
 */

public class TipDialog extends BaseDialog {
    public TipDialog(Context context) {
        super(context);
    }

    public TipDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected TipDialog(Context context, boolean cancelable, DialogInterface.OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onSetContentView() {
        setContentView(R.layout.dialog_note);
    }

    @Override
    protected void initViews() {
        mTextContent = (TextView) findViewById(R.id.note_content);
        mTextCancle = (TextView) findViewById(R.id.note_cancle);
        mTextConfirm = (TextView) findViewById(R.id.note_comfirm);
        mTextViewTitle = (TextView) findViewById(R.id.note_title);
        initWindow(0.75f, 0);
        setAnimate(R.style.animatedialog2);
    }

    @Override
    protected void onSetListener() {
        mTextCancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onDismiss();
            }
        });
        mTextConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onConfirm();
            }
        });
    }

    @Override
    protected void afterOnCreate(Bundle savedInstanceState) {
        if (mContent != null) {
            mTextContent.setText(mContent);
        }
        if (mConfirm != null) {
            mTextConfirm.setText(mConfirm);
        }
        if (mCancle != null) {
            mTextCancle.setText(mCancle);
        }
        if (mTitle != null) {
            mTextViewTitle.setText(mTitle);
        }
    }

    private String mContent;
    private String mConfirm;
    private String mCancle;
    private String mTitle;
    private TextView mTextContent;
    private TextView mTextCancle;
    private TextView mTextConfirm;
    private TextView mTextViewTitle;

    public void setContent(String str) {
        mContent = str;
        if (mTextContent != null) {
            mTextContent.setText(mContent);
        }
    }

    public void setConfirm(String str) {
        mConfirm = str;
        if (mTextConfirm != null) {
            mTextConfirm.setText(mConfirm);
        }
    }

    public void setTitle(String str) {
        mTitle = str;
        if (mTextViewTitle != null) {
            mTextViewTitle.setText(mTitle);
        }
    }

    public void setCancle(String str) {
        mCancle = str;
        if (mTextCancle != null) {
            mTextCancle.setText(mCancle);
        }
    }


    private Listener listener;

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    public static class Listener {
        public void onConfirm() {

        }

        public void onDismiss() {

        }
    }
}
